const path = require("path");
/**
 *
 * @param {String} dir
 */
function resolve(dir) {
  return path.resolve(dir);
}
let env = process.env.NODE_ENV;
let outputDirName;
switch (env) {
  case "production":
    outputDirName = "proDist";
    break;
  case "test":
    outputDirName = "testDist";
    break;
  default:
    outputDirName = "dist";
}

module.exports = {
  outputDir: outputDirName,
  publicPath: "./",
  lintOnSave: false,
  devServer: {
    // port:env==="qf"?8081:8080,
    proxy: {
      "/api": {
        target: "http://chst.vip:1902",
        pathRewrite: {
          "^/api": "",
        },
      },
    },
  },
  chainWebpack: (config) => {
    config.resolve.alias
      .set("pages", resolve("src/pages"))
      .set("component", resolve("src/component"))
      .set("src", resolve("src"))
      .set("~", resolve("src/pages"));
  },
};
